package com.czbgradefive.shop.service.impl;

import java.util.Date;
import java.util.List;
import com.czbgradefive.common.core.utils.DateUtils;
import com.czbgradefive.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.czbgradefive.shop.mapper.MallProductSkuInfoMapper;
import com.czbgradefive.shop.domain.MallProductSkuInfo;
import com.czbgradefive.shop.service.IMallProductSkuInfoService;

/**
 * 商品SKUService业务层处理
 * 
 * @author czbgradefive
 * @date 2024-05-09
 */
@Service
public class MallProductSkuInfoServiceImpl implements IMallProductSkuInfoService 
{
    @Autowired
    private MallProductSkuInfoMapper mallProductSkuInfoMapper;

    /**
     * 查询商品SKU
     * 
     * @param id 商品SKU主键
     * @return 商品SKU
     */
    @Override
    public MallProductSkuInfo selectMallProductSkuInfoById(Long id)
    {
        return mallProductSkuInfoMapper.selectMallProductSkuInfoById(id);
    }

    /**
     * 查询商品SKU列表
     * 
     * @param mallProductSkuInfo 商品SKU
     * @return 商品SKU
     */
    @Override
    public List<MallProductSkuInfo> selectMallProductSkuInfoList(MallProductSkuInfo mallProductSkuInfo)
    {
        return mallProductSkuInfoMapper.selectMallProductSkuInfoList(mallProductSkuInfo);
    }

    /**
     * 新增商品SKU
     * 
     * @param mallProductSkuInfo 商品SKU
     * @return 结果
     */
    @Override
    public int insertMallProductSkuInfo(MallProductSkuInfo mallProductSkuInfo)
    {
        Long userid = SecurityUtils.getLoginUser().getUserid();
        Date nowDate = DateUtils.getNowDate();

        mallProductSkuInfo.setCreateBy(String.valueOf(userid));
        mallProductSkuInfo.setUpdateBy(String.valueOf(userid));
        mallProductSkuInfo.setCreateTime(DateUtils.getNowDate());
        return mallProductSkuInfoMapper.insertMallProductSkuInfo(mallProductSkuInfo);
    }

    /**
     * 修改商品SKU
     * 
     * @param mallProductSkuInfo 商品SKU
     * @return 结果
     */
    @Override
    public int updateMallProductSkuInfo(MallProductSkuInfo mallProductSkuInfo)
    {
        mallProductSkuInfo.setUpdateTime(DateUtils.getNowDate());
    Long userid = SecurityUtils.getLoginUser().getUserid();
    mallProductSkuInfo.setUpdateBy(String.valueOf(userid));
        return mallProductSkuInfoMapper.updateMallProductSkuInfo(mallProductSkuInfo);
    }

    /**
     * 批量删除商品SKU
     * 
     * @param ids 需要删除的商品SKU主键
     * @return 结果
     */
    @Override
    public int deleteMallProductSkuInfoByIds(Long[] ids)
    {
        return mallProductSkuInfoMapper.deleteMallProductSkuInfoByIds(ids);
    }

    /**
     * 删除商品SKU信息
     * 
     * @param id 商品SKU主键
     * @return 结果
     */
    @Override
    public int deleteMallProductSkuInfoById(Long id)
    {
        return mallProductSkuInfoMapper.deleteMallProductSkuInfoById(id);
    }
}
